$(function () {
    function updateFlower(number) {
        var image = new Image();
        $(image).load(function () {
            $(this)
                .attr('width', this.width)
                .attr('height', this.height);
        }).attr('src', 'images/refreshflowers/' + number + '.jpg');
        var count = 'Refresh Flowers (' + number + ')';
        $('#refreshFlowersImage img').get(0).src = image;
        $('#refreshFlowersText').html(count);
        alert(image);
    }
    function refreshFlowers() {
        $.get(
            'refreshFlowers.php',
            {personid: $.query.get('personid')},
            function (data) {
                updateFlower(data);
            }
        );
        return false;
    }
    $('#refreshFlowersImage').click(refreshFlowers);
    $('#refreshFlowersText').click(refreshFlowers);
});
